package com.linwen.javase.annotation;



import org.junit.Test;

public class TestAnnotation {
	//测试toString的@Override注解
	//test
	//测试过时的@Deprecated注解
	//List测试@SuppressWarnings注解
	@Test
	public void test1() {
		Student Student = new Student();
		
		Student.setName("Tom");
		Student.setAge(18);
		Student.setScore(78);
		
		Student.say();
		Student.toString();

		System.out.println(Student);
	}
	//测试自定义注解
	@Test
	public void tets2() {
		//反射获取类x信息
		Class<Student> studentClass = Student.class;
		//获取annotation信息
		Myannotation annotation = studentClass.getAnnotation(Myannotation.class);
		String name = annotation.name();
		int age = annotation.age();
		int score = annotation.score();
		
		try {
			//创建实例
			Student student2 = studentClass.newInstance();
			//将注解的值赋给实例
			student2.setName(name);
			student2.setAge(age);
			student2.setScore(score);
			System.out.println(student2.toString());
		} catch (InstantiationException | IllegalAccessException e) {
			e.printStackTrace();
		}
		
	}
	
}
